package com.pdstudio.carrecom.ui.activity.appointment;

import com.pdstudio.carrecom.R;
import com.pdstudio.carrecom.bean.CarSelectInfo;
import com.pdstudio.carrecom.ui.fragment.account.FragmentRegisterS1;
import com.pdstudio.carrecom.ui.fragment.account.FragmentRegisterS2;
import com.pdstudio.carrecom.ui.fragment.appointment.fragmentappointdrive1;
import com.pdstudio.carrecom.ui.fragment.appointment.fragmentappointdrive2;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

/**
 * 预约驾驶
 * 类: ActivityAppointDrive <br>
 * 描述: TODO <br>
 * 作者: xiangzhaoyu  <br>
 * 时间: 2015-6-3 下午3:40:30
 */
public class ActivityAppointDrive extends Activity {

	private View customLiveIndexTitleView;
	private TextView txtTitle;
	private ImageView ivBack;
	
	private int currentFrag=1;//1表示step1,2表示step2
	private Fragment currentFragment;
	
	public CarSelectInfo currentc=new CarSelectInfo();//当前选中的车型
	public String CarSelectTitle;//服务端太渣，这东西还要自己拼
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_appoint_drive_main);

		initTitle();
		InitialView();
	}
	
	private void initTitle() {
		txtTitle = (TextView) findViewById(R.id.title_text_nav);

		txtTitle.setText("预约试驾");

		ivBack = (ImageView) findViewById(R.id.title_back);
		ivBack.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();				
			}
		});
	}
	
	private void InitialView(){
		switch(currentFrag){
		case 1:{
			currentFragment=new fragmentappointdrive1();
			
		}break;
		case 2:{
			currentFragment=new fragmentappointdrive2();
		}break;
		default:{
			currentFragment=new fragmentappointdrive1();
		}break;
		}
		openFragment(currentFragment);
	}
	
	public void openFragment(Fragment f){
		try{
			getFragmentManager().beginTransaction()
			.replace(R.id.fg_fragment, f).commit(); // 允许丢失状态
			currentFragment=f;
		}catch(Exception e){}
	}
	
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        /*在这里，我们通过碎片管理器中的Tag，就是每个碎片的名称，来获取对应的fragment*/
        
        /*然后在碎片中调用重写的onActivityResult方法*/
        currentFragment.onActivityResult(requestCode, resultCode, data);
    }

	
}
